package com.hardydou.system.service.impl;

import com.hardydou.system.mapper.SystemLoginLogMapper;
import com.hardydou.system.model.SystemLoginLog;
import com.hardydou.system.service.ISystemLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：hardy
 * @description：登录日志
 * @date ：Created in 2020/6/2
 * @Copyright ：Hardydou.com
 */
@Service
public class SystemLoginLogServiceImpl implements ISystemLoginLogService {

    @Autowired
    SystemLoginLogMapper loginLogMapper;

    @Override
    public SystemLoginLog findById(Long loginId) {
        return loginLogMapper.selectByPrimaryKey(loginId);
    }

    @Override
    public List<SystemLoginLog> findAll(Map params) {
        return loginLogMapper.findAll(params);
    }

    @Override
    public int add(SystemLoginLog loginLog) {
        Date date = new Date();
        loginLog.setCtime(date);
        loginLog.setUtime(date);
        return loginLogMapper.insert(loginLog);
    }

    @Override
    public int update(SystemLoginLog loginLog) {
        return loginLogMapper.updateByPrimaryKeySelective(loginLog);
    }

    @Override
    public int deleteById(Long loginId) {
        return loginLogMapper.deleteByPrimaryKey(loginId);
    }
}
